package ro.sep.web.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;

import ro.sep.web.dao.IProductDao;
import ro.sep.web.dao.mappers.SearchResultMapper;
import ro.sep.web.services.model.SearchResult;

public class ProductDaoImpl extends JdbcTemplate implements IProductDao {

	@Override
	@Transactional
	public List<SearchResult> getSearchResult(String word, String siteName) {
		String query = "SELECT productId, productName, description, price, url FROM products\n" +
				"WHERE (description like '%" + word +"%' or productName like '%" + word
				+ "%') AND siteName=?";
		return query(query, new Object[] {siteName}, new SearchResultMapper());
	}

}
